package com.dacool.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.ViewGroup.LayoutParams;

import com.dacool.app.sale.R;
import com.dacool.util.ViewUtils;
import com.dacool.view.GifView;

public class MyProgressDialog extends Dialog {

	private GifView gifView;

	public MyProgressDialog(Context context) {
		this(context, R.style.customDialog);
	}

	public MyProgressDialog(Context context, int theme) {
		super(context, R.style.customDialog);
		gifView = new GifView(context);
		gifView.setResID(R.raw.anim);
		this.setCancelable(false);
		this.getWindow().getAttributes().gravity = Gravity.CENTER;
		this.getWindow().getAttributes().dimAmount = 0;
	}

	@Override
	public void onAttachedToWindow() {
		// TODO Auto-generated method stub

		LayoutParams lp = new LayoutParams(ViewUtils.rp(60), ViewUtils.rp(60));
		this.addContentView(gifView, lp);
		super.onAttachedToWindow();
	}

	@Override
	public void onDetachedFromWindow() {
		// TODO Auto-generated method stub
		ViewUtils.removeFromSuperView(gifView);
		super.onDetachedFromWindow();
	}

}
